package cc.idoone.spring_boot_hello.mybatis.h2.service;

import cc.idoone.spring_boot_hello.mybatis.h2.entity.User;
import cc.idoone.spring_boot_hello.mybatis.h2.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @auther hemj
 * @since 2017/9/25
 */
@Service
@Transactional(transactionManager = "h2MyBatisTransactionManager")
public class MyUserServiceImpl implements MyUserService {

	private UserMapper userMapper;

	@Autowired
	public MyUserServiceImpl(UserMapper userMapper) {
		this.userMapper = userMapper;
	}

	@Override
	public void createTable() {
		userMapper.createTable();
	}

	@Override
	public Integer addUser(User user) {
		return userMapper.addUser(user);
	}

	@Override
	public Integer deleteUserById(Integer id) {
		return userMapper.deleteUserById(id);
	}

	@Override
	public Integer updateUser(User user) {
		return userMapper.updateUser(user);
	}

	@Override
	public User getById(Integer id) {
		return userMapper.getById(id);
	}

	@Override
	public List<User> queryUserList() {
		return userMapper.queryUserList();
	}
}
